﻿@{
    ViewBag.Title = "新增用户";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@model UserDto
<div class="row">
    <div class="panel panel-default">
        <div class="panel-heading">
            新增用户
        </div>
        <div class="panel-body">
            @using (Html.BeginForm("Add", "User", FormMethod.Post, new { id = "postForm", @class = "form-horizontal", onsubmit = "return validateCallback(this,navTabAjaxDone)" }))
            {
                <div class="form-group">
                    <label class="col-sm-3 control-label">
                        名称：</label>
                    <div class="col-sm-8">
                        @Html.TextBoxFor(m => m.ShortName, new { @class = "form-control" })
                        @Html.ValidationMessageFor(m => m.ShortName)
                        <span class="help-block m-b-none"><i class="fa fa-info-circle"></i>这里写点提示的内容</span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">
                        角色：</label>
                    <div class="col-sm-8">
                        @Html.DropDownListFor(m => m.RoleId, Model.RoleList, new { @class = "form-control chosen-select" })
                        @Html.ValidationMessageFor(m => m.RoleId)
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">
                        登录账号：</label>
                    <div class="col-sm-8">
                        @Html.TextBoxFor(m => m.LoginNo, new { @class = "form-control" })
                        @Html.ValidationMessageFor(m => m.LoginNo)
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">
                        密码：</label>
                    <div class="col-sm-8">
                        @Html.PasswordFor(m => m.PassWord, new { @class = "form-control" })
                        @Html.ValidationMessageFor(m => m.PassWord)
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">
                        联系方式：</label>
                    <div class="col-sm-8">
                        @Html.TextBoxFor(m => m.Contact, new { @class = "form-control" })
                        @Html.ValidationMessageFor(m => m.Contact)
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">
                        是否启用：</label>
                    <div class="col-sm-8">
                        @Html.CheckBoxFor(m => m.IsActive, new { @class = "js-switch" })
                    </div>
                </div>
                <div class="form-group">
                 <label class="col-sm-3 control-label">
                        上传：</label>
                    <div class="col-sm-8">
                        <div id="uploader"></div>
                       <input type="hidden" id="hfFilePath" />
                    </div>
                </div>
             
                <div class="form-group">
                    <div class="col-sm-4 col-sm-offset-3">
                        <button class="btn btn-primary" type="submit">
                            提交</button>
                        <a class="btn btn-default" type="button">取消</a>
                    </div>
                </div>
            }
        </div>
    </div>
</div>

@section Customer_Css{
    <link href="@Url.Content("~/hplus/css/plugins/webuploader/webuploader.css")" rel="stylesheet" type="text/css" />
}
@section Customer_Js{
    <script>
        var applicationPath = "@(Href("~")=="/"?"":Href("~"))"; 
    </script>
    <script src="@Url.Content("~/hplus/js/plugins/webuploader/webuploader.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/hplus/js/plugins/webuploader/webuploader.extend.js")" type="text/javascript"></script>
    <script>
        $("#uploader").powerWebUpload({ hiddenInputId: "uploadhidden" }); 
    </script>
}

  @* <div class="form-group">
                    <label class="col-sm-3 control-label">
                        上传：</label>
                    <div class="col-sm-8">
                        <input type="file" name="file_upload" id="file_upload" />
                        <p>
                            <input type="button" id="btnUpload" onclick="javascript:$('#file_upload').uploadify('upload','*')"
                                value="上传" />
                            &nbsp;&nbsp;&nbsp;&nbsp;
                            <input type="button" id="btnCancelUpload" onclick="javascript:$('#file_upload').uploadify('cancel')"
                                value="取消" />
                        </p>
                        <br />
                        <div id="fileQueue" class="fileQueue">
                        </div>
                    </div>
                </div>*@

@*@section Customer_Css{
    <link href="@Url.Content("~/hplus/js/plugins/Uploadify/css/uploadify.css")" rel="stylesheet" type="text/css" />
}
@section Customer_Js{
    <script src="@Url.Content("~/hplus/js/plugins/Uploadify/js/swfobject.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/hplus/js/plugins/Uploadify/js/uploadify3.2.1/jquery.uploadify.js")" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            $('#file_upload').uploadify({
                'auto': false, //选择文件后是否自动上传，默认为true
                //'buttonClass': 'some-class',
                //'buttonImage': '/Uploadify/icon/btn.png',//选择文件按钮   
                'buttonText': '浏   览', //设置按钮文本
                //'debug': true,//是否打开调试模式，默认为false
                'fileSizeLimit': '20MB', //单个文件大小，0为无限制，可接受KB,MB,GB等单位的字符串值
                'fileTypeDesc': 'Image Files', //文件描述
                'fileTypeExts': '*.*', //允许上传的文件类型
                //'formData': { 'someKey': 'someValue', 'someOtherKey': 1 },//传参数
                //'height': 50,//按钮的高度
                //'itemTemplate': '<div id="${fileID}" class="uploadify-queue-item">\
                //                    <div class="cancel">\
                //                      <a href="javascript:$(\'#${instanceID}\').uploadify(\'cancel\', \'${fileID}\')">X</a>\
                //                    </div>\
                //                    <span class="fileName">${fileName} (${fileSize})</span><span class="data"></span>\
                //                 </div>',//队列中的每个项目一个特殊的HTML模板
                //'method': 'post',//请求方式"get"或者"post",默认为"post"   
                'multi': true, //是否允许同时选择多个文件，默认为true
                //'overrideEvents': ['onUploadError'],//不执行某个默认事件如：onUploadError上传失败事件  
                //'preventCaching': false,//是否取消缓存，默认为true没有缓存
                //'progressData': 'speed',//上传进度条显示，'percentage'or'speed'默认为'percentage'
                'queueID': 'fileQueue', //队列的ID,一个存放上传文件div的ID
                //'queueSizeLimit':1,//可同事选择上传文件的数量，默认为999
                //'removeCompleted': false,//是否移除在队列中上传完成的文件，默认为true
                //'removeTimeout': 10,//在队列中上传完成延迟多少秒移除，默认为3秒
                //'requeueErrors': true,//上传失败是否重新上传，默认为false
                //'successTimeout': 5,//上传成功之后等待响应时间swf成功，默认为30秒
                'swf': '@Url.Content("~/hplus/js/plugins/Uploadify/js/uploadify3.2.1/uploadify.swf")', //FLash文件路径
                'uploader': '@Url.Content("~/SimpleCommon/Upload")', //上传文件处理后台页面
                //'uploadLimit': 1,//允许上传最大文件数，超过onUploadError事件被触发，默认999
                //'width': 300,//按钮宽度
                /**********************************************事件***********************************************************************/
                //'onCancel': function (file) {//取消单个文件上传触发
                //    alert('The file ' + file.name + ' was cancelled.')
                //},
                //'onClearQueue': function (queueItemCount) {//取消队列中所用上传文件触发
                //    alert(queueItemCount + ' file(s) were removed from the queue');
                //},
                //'onDestroy': function () {//销毁触发
                //    alert('I am getting destroyed!');
                //},
                //'onDialogClose': function (queueData) {//关闭窗口时触发
                //    //queueData属性如下
                //    //filesSelected：在浏览文件对话框中选择文件的数量
                //    //filesQueued：添加到队列中文件的数量（即没有返回错误）
                //    //filesReplaced：在队列中替换的文件数
                //    //filesCancelled：文件已被添加到队列中取消数（不更换）
                //    //filesErrored：返回错误的文件数
                //    alert(queueData.filesQueued + ' files were queued of ' + queueData.filesSelected + ' selected files. There are ' + queueData.queueLength + ' total files in the queue.');
                //},
                //'onDialogOpen': function () {//打开对话框时触发
                //},
                //'onDisable': function () {//禁用上传功能触发
                //    alert('You have disabled Uploadify!');
                //},
                //'onEnable': function () {//启用上传功能触发
                //    alert('You can use Uploadify again.');
                //},
                'onFallback': function () {//初始化浏览器不兼容触发 也可监视浏览器是否禁用flash播放插件
                    alert('Flash was not detected.');
                },
                //'onInit': function (instance) {//初始化时触发
                //    alert('The queue ID is ' + instance.settings.queueID);
                //},
                //'onQueueComplete': function (queueData) {//队列中所有文件处理完成触发
                //    //queueData属性如下
                //    //uploadsSuccessful：上传的文件数量已顺利完成
                //    //uploadsErrored：传回错误的上传数量
                //    alert(queueData.uploadsSuccessful + ' files were successfully uploaded.');
                //},
//                'onSelect': function (file) {//选择文件时触发
//                    if(file.name.substring(0,file.name.lastIndexOf('.')) != $("#BillNo").val()){
//                        alert("图片文件名必须和票据号一致");
//                        $('#file_upload').uploadify('cancel')
//                        return false;
//                    }
//                },
                //'onSelectError': function () {//选择文件出现错误时触发，如超出文件大小设置
                //    //返回file
                //    //返回errorCode
                //    //返回errorMsg
                //    //alert(errorCode);
                //    //alert('The file ' + file.name + ' returned an error and was not added to the queue.');
                //},
                //'onSWFReady': function () {//当Flash对象加载触发。
                //    alert('The Flash file is ready to go.');
                //},
                //'onUploadComplete': function (file) {//当上传完成后是否成功，或返回错误为每个文件触发一次
                //    alert('The file ' + file.name + ' finished processing.');
                //},
                //'onUploadError': function (file, errorCode, errorMsg, errorString) {//上传文件失败时触发
                //    alert('The file ' + file.name + ' could not be uploaded: ' + errorString);
                //},
                //'onUploadProgress': function (file, bytesUploaded, bytesTotal, totalBytesUploaded, totalBytesTotal) {//上传进度数据
                //    $('#progress').html(totalBytesUploaded + ' bytes uploaded of ' + totalBytesTotal + ' bytes.');
                //},
                //'onUploadStart': function (file) {//开始上传触发
                //    alert('Starting to upload ' + file.name);
                //},
                'onUploadSuccess': function (file, data, response) {//上传成功后触发，每个文件都触发
                    alert(data);
                    if (data) {
                        $("#ImgHref", $.pdialog.getCurrent()).show();
                        $("#FileName", $.pdialog.getCurrent()).val(data);
                        $("#ImgHref", $.pdialog.getCurrent()).attr("href","@Url.Content("~/Uploadify_Temp/")" + data);
                    }else{
                        $("#ImgHref", $.pdialog.getCurrent()).hide();
                        $("#FileName", $.pdialog.getCurrent()).val("");
                    }
                }
            });
        });
    </script>
}*@
